{extend name="layout/layout"/}
{block name="body"}
<body data-type="widgets">
{/block}
{block name="content"}
<!-- 内容区域 -->
<div class="tpl-content-wrapper">
    <div class="container-fluid am-cf">
        <div class="row">
            <div class="am-u-sm-12 am-u-md-12 am-u-lg-9">
                <div class="page-header-heading"><span class="am-icon-home page-header-heading-icon"></span> 会员编辑 </div>
            </div>
        </div>
    </div>
    <div class="row-content am-cf">
        <div class="row">
            <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                <div class="widget am-cf">
                    <div class="widget-body am-fr">
                        <form class="am-form tpl-form-border-form tpl-form-border-br">
                            <div class="am-form-group">
                                <label for="user-name" class="am-u-sm-3 am-form-label">用户名 <span class="tpl-form-line-small-title">Name</span></label>
                                <div class="am-u-sm-9">
                                    <input type="text" class="tpl-form-input js-name" id="user-name" value="{$list.member_name}" >
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label for="user-mobile" class="am-u-sm-3 am-form-label">手机号码 <span class="tpl-form-line-small-title">Mobile</span></label>
                                <div class="am-u-sm-9">
                                    <input type="text" class="tpl-form-input js-mobile" id="user-mobile" value="{$list.member_mobile}" >
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-mobile" class="am-u-sm-3 am-form-label">城市 <span class="tpl-form-line-small-title">City</span></label>
                                <div class="am-u-sm-9">
                                    <input type="text" class="tpl-form-input js-city" id="user-city" value="{$list.member_city}" >
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-mobile" class="am-u-sm-3 am-form-label">区县 <span class="tpl-form-line-small-title">Area</span></label>
                                <div class="am-u-sm-9">
                                    <input type="text" class="tpl-form-input js-area" id="user-area" value="{$list.member_area}" >
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-mobile" class="am-u-sm-3 am-form-label">小区 <span class="tpl-form-line-small-title">Plot</span></label>
                                <div class="am-u-sm-9">
                                    <input type="text" class="tpl-form-input" id="user-plot" value="{$list.member_plot}" >
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-mobile" class="am-u-sm-3 am-form-label">新旧 <span class="tpl-form-line-small-title">Status</span></label>
                                <div class="am-u-sm-9">
                                    <div class="tpl-switch " >
                                        <input type="checkbox" class="ios-switch bigswitch tpl-switch-btn am-margin-top-xs js-status" checked="">
                                        <div class="tpl-switch-btn-view">
                                            <div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-mobile" class="am-u-sm-3 am-form-label">住房面积 <span class="tpl-form-line-small-title">Size</span></label>
                                <div class="am-u-sm-9">
                                    <input type="text" class="tpl-form-input js-size" id="user-size" value="{$list.member_size}" >
                                    <small>单位面积m²</small>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-mobile" class="am-u-sm-3 am-form-label">是否拨打 <span class="tpl-form-line-small-title">State</span></label>
                                <div class="am-u-sm-9">
                                    <div class="tpl-switch">
                                        <input type="checkbox" class="ios-switch bigswitch tpl-switch-btn am-margin-top-xs js-state" checked="">
                                        <div class="tpl-switch-btn-view">
                                            <div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-intro" class="am-u-sm-3 am-form-label">备注</label>
                                <div class="am-u-sm-9">
                                    <textarea class="js-remark" rows="10" id="user-intro">{$list.member_remark}</textarea>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <div class="am-u-sm-9 am-u-sm-push-3">
                                    <button type="button" onclick="edit()" class="am-btn am-btn-primary tpl-btn-bg-color-success ">提交</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(document).ready(function(){
        var state="{$list.member_state}";
        if(state == 10){
            $('.js-state').attr('checked','checked');
        }else if(state == 30 ){
           // $('.js-state').attr('checked',false);
           $('.js-state').removeAttr('checked');
        }
        var status="{$list.member_status}";
        if(status == 10){
            $('.js-status').attr('checked','checked');
        }else if(status == 30){
           // $('.js-state').attr('checked',false);
            $('.js-status').removeAttr('checked');
        }



    })

    function edit(){
        var id="{$list.member_id}";
        var name=$('.js-name').val();
        var mobile=$('.js-mobile').val();
        var city=$('.js-city').val();
        var area=$('.js-area').val();
        var plot=$('.js-plot').val();
        var size=$('.js-size').val();
        var remark=$('.js-remark').val();
        if($(".js-state").prop('checked')==true){
            var state = 10;
        }else{
            var state = 30;
        }
        if($(".js-status").prop('checked')==true){
            var status=10;
        }else{
            var status=30;
        }

        layer.confirm('确定修改？',function(index){
            //alert(size);return false;
            $.ajax({
                type:"post",
                async:false,
                dataType:'json',
                url:"{:url('@memberEdit')}",
                data:{
                    member_id:id,
                    member_name:name,
                    member_mobile:mobile,
                    member_city:city,
                    member_area:area,
                    member_plot:plot,
                    member_size:size,
                    member_remark:remark,
                    member_state:state,
                    member_status:status,
                },
                success:function(data){
                 //  console.dir(data);return false;
                    if(data === true){
                        layer.msg('修改成功',{icon:1});
                        setTimeout(function(){
                            window.history.go(0);
                        },1000);
                    }else{
                        console.dir(data);
                        layer.msg('修改失败',{icon:5});
                    }
                }
            })
            layer.close(index);
        })

    }
</script>
{/block}